package org.eddycar.jproyeddycar.contrato.vistas;

import org.jdesktop.observablecollections.ObservableList;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import javax.swing.JOptionPane;
import org.eddycar.jproyeddycar.comun.dao.DaoCliente;
import org.eddycar.jproyeddycar.comun.modelo.Cliente;
import org.eddycar.jproyeddycar.negocio.Control;
import org.eddycar.jproyeddycar.contrato.dao.DaoAdministracionFinanciamiento;
import org.eddycar.jproyeddycar.contrato.modelo.Cuota;
import org.eddycar.jproyeddycar.contrato.modelo.Financiamiento;

public class AdminFinanciamiento extends javax.swing.JDialog {

    DaoAdministracionFinanciamiento da;
    boolean error = false;
    int cambios = 0;
    Control ver = new Control();
    DaoCliente dc = new DaoCliente();
    Cuota cuota;
    Financiamiento administracionEncontrada = new Financiamiento();
    private Financiamiento administracionOriginal = new Financiamiento();
    Financiamiento administracionEditada = new Financiamiento();
    List<Cuota> cuotasRecuperadas = new ArrayList<Cuota>();
    List<Cuota> cuotasOriginales = new ArrayList<Cuota>();

    public AdminFinanciamiento() {
        initComponents();
        setLocationRelativeTo(this);
        txtValorCuota.setText("0");
        //panelAbono.setVisible(false);
        dcrFechaCuota.setDate(new Date());
    }

    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {
        bindingGroup = new org.jdesktop.beansbinding.BindingGroup();

        vistaValores = new javax.swing.JDialog();
        panelImage4 = new org.edisoncor.gui.panel.PanelImage();
        panelRound3 = new org.edisoncor.gui.panel.PanelRound();
        jLabel12 = new javax.swing.JLabel();
        btnGuardarNuevoPlazo = new javax.swing.JButton();
        jLabel11 = new javax.swing.JLabel();
        txtNuevoValorCuotas = new javax.swing.JTextField();
        spnNuevoPlazo = new javax.swing.JSpinner();
        jLabel8 = new javax.swing.JLabel();
        btnGuardar = new javax.swing.JButton();
        jLabel6 = new javax.swing.JLabel();
        txtSaldoAdeudadoSinInteres = new javax.swing.JTextField();
        jLabel13 = new javax.swing.JLabel();
        panelImage1 = new org.edisoncor.gui.panel.PanelImage();
        tabbedPaneVertical1 = new org.edisoncor.gui.tabbedPane.TabbedPaneVertical();
        panelImage2 = new org.edisoncor.gui.panel.PanelImage();
        panelImage3 = new org.edisoncor.gui.panel.PanelImage();
        panelRect1 = new org.edisoncor.gui.panel.PanelRect();
        pnlCuota = new javax.swing.JPanel();
        txtValorCuota = new javax.swing.JTextField();
        dcrFechaCuota = new com.toedter.calendar.JDateChooser();
        lblAbonoCuota = new javax.swing.JLabel();
        lblNumRecibo = new javax.swing.JLabel();
        lblValorCuota = new javax.swing.JLabel();
        txtAbonoCuota = new javax.swing.JTextField();
        lblFechaCuota = new javax.swing.JLabel();
        btnGuardarCuota = new javax.swing.JButton();
        txtNumeroRecibo = new javax.swing.JSpinner();
        jLabel7 = new javax.swing.JLabel();
        panelRound2 = new org.edisoncor.gui.panel.PanelRound();
        btnNuevoAbono = new javax.swing.JButton();
        btnNuevaCuota = new javax.swing.JButton();
        lblAbonoInicial = new javax.swing.JLabel();
        txtAbonoInicial = new javax.swing.JTextField();
        txtCuota = new javax.swing.JTextField();
        txtSaldoAdeudado = new javax.swing.JTextField();
        lblSaldoAdeudado = new javax.swing.JLabel();
        lblCuota = new javax.swing.JLabel();
        lblSaldoAdeudado1 = new javax.swing.JLabel();
        lblSaldoAdeudado2 = new javax.swing.JLabel();
        pnlCuotas = new javax.swing.JPanel();
        jScrollPane1 = new javax.swing.JScrollPane();
        tblCuotas = new javax.swing.JTable();
        panelRound1 = new org.edisoncor.gui.panel.PanelRound();
        lblCedulaCliente = new javax.swing.JLabel();
        txtCedulaCliente = new javax.swing.JTextField();
        btnBuscarAdministraciónFinanciamiento = new javax.swing.JButton();
        jLabel1 = new javax.swing.JLabel();
        btnGuardarTodo = new javax.swing.JButton();

        org.jdesktop.application.ResourceMap resourceMap = org.jdesktop.application.Application.getInstance().getContext().getResourceMap(AdminFinanciamiento.class);
        vistaValores.setTitle(resourceMap.getString("vistaValores.title")); // NOI18N
        vistaValores.setAlwaysOnTop(true);
        vistaValores.setMinimumSize(new java.awt.Dimension(420, 290));
        vistaValores.setName("vistaValores"); // NOI18N
        vistaValores.setResizable(false);

        panelImage4.setForeground(resourceMap.getColor("panelImage4.foreground")); // NOI18N
        panelImage4.setIcon(resourceMap.getIcon("panelImage4.icon")); // NOI18N
        panelImage4.setName("panelImage4"); // NOI18N

        panelRound3.setName("panelRound3"); // NOI18N

        jLabel12.setFont(resourceMap.getFont("jLabel12.font")); // NOI18N
        jLabel12.setForeground(resourceMap.getColor("jLabel12.foreground")); // NOI18N
        jLabel12.setText(resourceMap.getString("jLabel12.text")); // NOI18N
        jLabel12.setName("jLabel12"); // NOI18N

        btnGuardarNuevoPlazo.setText(resourceMap.getString("btnGuardarNuevoPlazo.text")); // NOI18N
        btnGuardarNuevoPlazo.setEnabled(false);
        btnGuardarNuevoPlazo.setName("btnGuardarNuevoPlazo"); // NOI18N
        btnGuardarNuevoPlazo.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnGuardarNuevoPlazoActionPerformed(evt);
            }
        });

        jLabel11.setFont(resourceMap.getFont("jLabel11.font")); // NOI18N
        jLabel11.setForeground(resourceMap.getColor("jLabel12.foreground")); // NOI18N
        jLabel11.setText(resourceMap.getString("jLabel11.text")); // NOI18N
        jLabel11.setName("jLabel11"); // NOI18N

        txtNuevoValorCuotas.setText(resourceMap.getString("txtNuevoValorCuotas.text")); // NOI18N
        txtNuevoValorCuotas.setEnabled(false);
        txtNuevoValorCuotas.setName("txtNuevoValorCuotas"); // NOI18N

        spnNuevoPlazo.setEnabled(false);
        spnNuevoPlazo.setName("spnNuevoPlazo"); // NOI18N

        jLabel8.setFont(resourceMap.getFont("lblCuota.font")); // NOI18N
        jLabel8.setForeground(resourceMap.getColor("jLabel12.foreground")); // NOI18N
        jLabel8.setText(resourceMap.getString("jLabel8.text")); // NOI18N
        jLabel8.setName("jLabel8"); // NOI18N

        btnGuardar.setText(resourceMap.getString("btnGuardar.text")); // NOI18N
        btnGuardar.setEnabled(false);
        btnGuardar.setName("btnGuardar"); // NOI18N
        btnGuardar.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnGuardarActionPerformed(evt);
            }
        });

        jLabel6.setFont(resourceMap.getFont("lblCuota.font")); // NOI18N
        jLabel6.setForeground(resourceMap.getColor("jLabel12.foreground")); // NOI18N
        jLabel6.setText(resourceMap.getString("jLabel6.text")); // NOI18N
        jLabel6.setName("jLabel6"); // NOI18N

        txtSaldoAdeudadoSinInteres.setText(resourceMap.getString("txtSaldoAdeudadoSinInteres.text")); // NOI18N
        txtSaldoAdeudadoSinInteres.setEnabled(false);
        txtSaldoAdeudadoSinInteres.setName("txtSaldoAdeudadoSinInteres"); // NOI18N

        javax.swing.GroupLayout panelRound3Layout = new javax.swing.GroupLayout(panelRound3);
        panelRound3.setLayout(panelRound3Layout);
        panelRound3Layout.setHorizontalGroup(
            panelRound3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(panelRound3Layout.createSequentialGroup()
                .addGroup(panelRound3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(panelRound3Layout.createSequentialGroup()
                        .addContainerGap()
                        .addGroup(panelRound3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addGroup(panelRound3Layout.createSequentialGroup()
                                .addGroup(panelRound3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                                    .addComponent(jLabel11)
                                    .addComponent(jLabel6)
                                    .addComponent(jLabel8))
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addGroup(panelRound3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                    .addComponent(txtNuevoValorCuotas, javax.swing.GroupLayout.PREFERRED_SIZE, 83, javax.swing.GroupLayout.PREFERRED_SIZE)
                                    .addGroup(panelRound3Layout.createSequentialGroup()
                                        .addComponent(spnNuevoPlazo, javax.swing.GroupLayout.PREFERRED_SIZE, 42, javax.swing.GroupLayout.PREFERRED_SIZE)
                                        .addGap(42, 42, 42)
                                        .addComponent(btnGuardarNuevoPlazo, javax.swing.GroupLayout.PREFERRED_SIZE, 98, javax.swing.GroupLayout.PREFERRED_SIZE))
                                    .addComponent(txtSaldoAdeudadoSinInteres, javax.swing.GroupLayout.PREFERRED_SIZE, 83, javax.swing.GroupLayout.PREFERRED_SIZE)))
                            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, panelRound3Layout.createSequentialGroup()
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 162, javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addComponent(jLabel12)
                                .addGap(156, 156, 156))))
                    .addGroup(panelRound3Layout.createSequentialGroup()
                        .addGap(130, 130, 130)
                        .addComponent(btnGuardar, javax.swing.GroupLayout.PREFERRED_SIZE, 126, javax.swing.GroupLayout.PREFERRED_SIZE)))
                .addContainerGap(16, Short.MAX_VALUE))
        );
        panelRound3Layout.setVerticalGroup(
            panelRound3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(panelRound3Layout.createSequentialGroup()
                .addGap(21, 21, 21)
                .addComponent(jLabel12)
                .addGap(18, 18, 18)
                .addGroup(panelRound3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(txtSaldoAdeudadoSinInteres, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabel11))
                .addGap(3, 3, 3)
                .addGroup(panelRound3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(spnNuevoPlazo, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(btnGuardarNuevoPlazo, javax.swing.GroupLayout.PREFERRED_SIZE, 27, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabel6))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(panelRound3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(txtNuevoValorCuotas, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabel8))
                .addGap(18, 18, 18)
                .addComponent(btnGuardar)
                .addContainerGap(16, Short.MAX_VALUE))
        );

        jLabel13.setFont(resourceMap.getFont("jLabel13.font")); // NOI18N
        jLabel13.setForeground(resourceMap.getColor("jLabel13.foreground")); // NOI18N
        jLabel13.setText(resourceMap.getString("jLabel13.text")); // NOI18N
        jLabel13.setName("jLabel13"); // NOI18N

        javax.swing.GroupLayout panelImage4Layout = new javax.swing.GroupLayout(panelImage4);
        panelImage4.setLayout(panelImage4Layout);
        panelImage4Layout.setHorizontalGroup(
            panelImage4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(panelImage4Layout.createSequentialGroup()
                .addGroup(panelImage4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(panelImage4Layout.createSequentialGroup()
                        .addContainerGap()
                        .addComponent(panelRound3, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
                    .addGroup(panelImage4Layout.createSequentialGroup()
                        .addGap(145, 145, 145)
                        .addComponent(jLabel13)))
                .addContainerGap())
        );
        panelImage4Layout.setVerticalGroup(
            panelImage4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, panelImage4Layout.createSequentialGroup()
                .addContainerGap(14, Short.MAX_VALUE)
                .addComponent(jLabel13)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addComponent(panelRound3, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap())
        );

        javax.swing.GroupLayout vistaValoresLayout = new javax.swing.GroupLayout(vistaValores.getContentPane());
        vistaValores.getContentPane().setLayout(vistaValoresLayout);
        vistaValoresLayout.setHorizontalGroup(
            vistaValoresLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(panelImage4, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
        );
        vistaValoresLayout.setVerticalGroup(
            vistaValoresLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(panelImage4, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
        );

        setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);
        setTitle(resourceMap.getString("Form.title")); // NOI18N
        setAlwaysOnTop(true);
        setMinimumSize(new java.awt.Dimension(701, 609));
        setName("Form"); // NOI18N
        setResizable(false);

        panelImage1.setIcon(resourceMap.getIcon("panelImage1.icon")); // NOI18N
        panelImage1.setName("panelImage1"); // NOI18N

        tabbedPaneVertical1.setBorder(javax.swing.BorderFactory.createLineBorder(resourceMap.getColor("tabbedPaneVertical1.border.lineColor"))); // NOI18N
        tabbedPaneVertical1.setName("tabbedPaneVertical1"); // NOI18N

        panelImage2.setBackground(resourceMap.getColor("panelImage2.background")); // NOI18N
        panelImage2.setName("panelImage2"); // NOI18N
        panelImage2.setOpaque(false);

        panelImage3.setBackground(resourceMap.getColor("panelImage3.background")); // NOI18N
        panelImage3.setName("panelImage3"); // NOI18N

        panelRect1.setName("panelRect1"); // NOI18N

        pnlCuota.setBorder(new javax.swing.border.SoftBevelBorder(javax.swing.border.BevelBorder.RAISED));
        pnlCuota.setName("pnlCuota"); // NOI18N

        txtValorCuota.setEditable(false);
        txtValorCuota.setText(resourceMap.getString("txtValorCuota.text")); // NOI18N
        txtValorCuota.setDisabledTextColor(resourceMap.getColor("txtValorCuota.disabledTextColor")); // NOI18N
        txtValorCuota.setEnabled(false);
        txtValorCuota.setName("txtValorCuota"); // NOI18N

        dcrFechaCuota.setEnabled(false);
        dcrFechaCuota.setName("dcrFechaCuota"); // NOI18N

        lblAbonoCuota.setFont(resourceMap.getFont("lblCuota.font")); // NOI18N
        lblAbonoCuota.setText(resourceMap.getString("lblAbonoCuota.text")); // NOI18N
        lblAbonoCuota.setName("lblAbonoCuota"); // NOI18N

        lblNumRecibo.setFont(resourceMap.getFont("lblCuota.font")); // NOI18N
        lblNumRecibo.setText(resourceMap.getString("lblNumRecibo.text")); // NOI18N
        lblNumRecibo.setName("lblNumRecibo"); // NOI18N

        lblValorCuota.setFont(resourceMap.getFont("lblCuota.font")); // NOI18N
        lblValorCuota.setText(resourceMap.getString("lblValorCuota.text")); // NOI18N
        lblValorCuota.setName("lblValorCuota"); // NOI18N

        txtAbonoCuota.setText(resourceMap.getString("txtAbonoCuota.text")); // NOI18N
        txtAbonoCuota.setEnabled(false);
        txtAbonoCuota.setName("txtAbonoCuota"); // NOI18N

        lblFechaCuota.setFont(resourceMap.getFont("lblCuota.font")); // NOI18N
        lblFechaCuota.setHorizontalAlignment(javax.swing.SwingConstants.RIGHT);
        lblFechaCuota.setText(resourceMap.getString("lblFechaCuota.text")); // NOI18N
        lblFechaCuota.setToolTipText(resourceMap.getString("lblFechaCuota.toolTipText")); // NOI18N
        lblFechaCuota.setName("lblFechaCuota"); // NOI18N

        btnGuardarCuota.setText(resourceMap.getString("btnGuardarCuota.text")); // NOI18N
        btnGuardarCuota.setEnabled(false);
        btnGuardarCuota.setName("btnGuardarCuota"); // NOI18N
        btnGuardarCuota.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnGuardarCuotaActionPerformed(evt);
            }
        });

        txtNumeroRecibo.setName("txtNumeroRecibo"); // NOI18N

        jLabel7.setFont(resourceMap.getFont("lblCuota.font")); // NOI18N
        jLabel7.setText(resourceMap.getString("jLabel7.text")); // NOI18N
        jLabel7.setName("jLabel7"); // NOI18N

        javax.swing.GroupLayout pnlCuotaLayout = new javax.swing.GroupLayout(pnlCuota);
        pnlCuota.setLayout(pnlCuotaLayout);
        pnlCuotaLayout.setHorizontalGroup(
            pnlCuotaLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(pnlCuotaLayout.createSequentialGroup()
                .addGroup(pnlCuotaLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                    .addComponent(lblNumRecibo)
                    .addComponent(lblValorCuota)
                    .addGroup(pnlCuotaLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                        .addComponent(lblFechaCuota, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                        .addComponent(lblAbonoCuota, javax.swing.GroupLayout.Alignment.TRAILING)))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(pnlCuotaLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(pnlCuotaLayout.createSequentialGroup()
                        .addComponent(txtAbonoCuota, javax.swing.GroupLayout.PREFERRED_SIZE, 68, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addGap(18, 18, 18)
                        .addComponent(btnGuardarCuota, javax.swing.GroupLayout.PREFERRED_SIZE, 90, javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addComponent(txtNumeroRecibo, javax.swing.GroupLayout.PREFERRED_SIZE, 50, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addGroup(pnlCuotaLayout.createSequentialGroup()
                        .addGap(16, 16, 16)
                        .addComponent(jLabel7))
                    .addComponent(txtValorCuota, javax.swing.GroupLayout.PREFERRED_SIZE, 65, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(dcrFechaCuota, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );
        pnlCuotaLayout.setVerticalGroup(
            pnlCuotaLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(pnlCuotaLayout.createSequentialGroup()
                .addComponent(jLabel7)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addGroup(pnlCuotaLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(txtNumeroRecibo, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(lblNumRecibo))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(pnlCuotaLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(lblValorCuota)
                    .addComponent(txtValorCuota, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(pnlCuotaLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(dcrFechaCuota, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(lblFechaCuota))
                .addGap(6, 6, 6)
                .addGroup(pnlCuotaLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(txtAbonoCuota, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(lblAbonoCuota)
                    .addComponent(btnGuardarCuota, javax.swing.GroupLayout.PREFERRED_SIZE, 25, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );

        javax.swing.GroupLayout panelRect1Layout = new javax.swing.GroupLayout(panelRect1);
        panelRect1.setLayout(panelRect1Layout);
        panelRect1Layout.setHorizontalGroup(
            panelRect1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(panelRect1Layout.createSequentialGroup()
                .addGap(180, 180, 180)
                .addComponent(pnlCuota, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap(146, Short.MAX_VALUE))
        );
        panelRect1Layout.setVerticalGroup(
            panelRect1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(panelRect1Layout.createSequentialGroup()
                .addGap(21, 21, 21)
                .addComponent(pnlCuota, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap(25, Short.MAX_VALUE))
        );

        panelRound2.setName("panelRound2"); // NOI18N

        btnNuevoAbono.setText(resourceMap.getString("btnNuevoAbono.text")); // NOI18N
        btnNuevoAbono.setEnabled(false);
        btnNuevoAbono.setName("btnNuevoAbono"); // NOI18N
        btnNuevoAbono.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnNuevoAbonoActionPerformed(evt);
            }
        });

        btnNuevaCuota.setText(resourceMap.getString("btnNuevaCuota.text")); // NOI18N
        btnNuevaCuota.setEnabled(false);
        btnNuevaCuota.setName("btnNuevaCuota"); // NOI18N
        btnNuevaCuota.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnNuevaCuotaActionPerformed(evt);
            }
        });

        lblAbonoInicial.setFont(resourceMap.getFont("lblCuota.font")); // NOI18N
        lblAbonoInicial.setForeground(resourceMap.getColor("lblAbonoInicial.foreground")); // NOI18N
        lblAbonoInicial.setText(resourceMap.getString("lblAbonoInicial.text")); // NOI18N
        lblAbonoInicial.setName("lblAbonoInicial"); // NOI18N

        txtAbonoInicial.setEditable(false);
        txtAbonoInicial.setText(resourceMap.getString("txtAbonoInicial.text")); // NOI18N
        txtAbonoInicial.setBorder(javax.swing.BorderFactory.createEtchedBorder());
        txtAbonoInicial.setName("txtAbonoInicial"); // NOI18N

        txtCuota.setEditable(false);
        txtCuota.setText(resourceMap.getString("txtCuota.text")); // NOI18N
        txtCuota.setBorder(javax.swing.BorderFactory.createEtchedBorder());
        txtCuota.setName("txtCuota"); // NOI18N

        txtSaldoAdeudado.setEditable(false);
        txtSaldoAdeudado.setText(resourceMap.getString("txtSaldoAdeudado.text")); // NOI18N
        txtSaldoAdeudado.setBorder(javax.swing.BorderFactory.createEtchedBorder());
        txtSaldoAdeudado.setName("txtSaldoAdeudado"); // NOI18N

        lblSaldoAdeudado.setFont(resourceMap.getFont("lblCuota.font")); // NOI18N
        lblSaldoAdeudado.setForeground(resourceMap.getColor("lblSaldoAdeudado.foreground")); // NOI18N
        lblSaldoAdeudado.setText(resourceMap.getString("lblSaldoAdeudado.text")); // NOI18N
        lblSaldoAdeudado.setName("lblSaldoAdeudado"); // NOI18N

        lblCuota.setFont(resourceMap.getFont("lblCuota.font")); // NOI18N
        lblCuota.setForeground(resourceMap.getColor("lblCuota.foreground")); // NOI18N
        lblCuota.setText(resourceMap.getString("lblCuota.text")); // NOI18N
        lblCuota.setName("lblCuota"); // NOI18N

        javax.swing.GroupLayout panelRound2Layout = new javax.swing.GroupLayout(panelRound2);
        panelRound2.setLayout(panelRound2Layout);
        panelRound2Layout.setHorizontalGroup(
            panelRound2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, panelRound2Layout.createSequentialGroup()
                .addGap(22, 22, 22)
                .addGroup(panelRound2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                    .addComponent(lblAbonoInicial)
                    .addComponent(lblCuota))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(panelRound2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                    .addComponent(txtCuota, javax.swing.GroupLayout.DEFAULT_SIZE, 98, Short.MAX_VALUE)
                    .addComponent(txtAbonoInicial, javax.swing.GroupLayout.PREFERRED_SIZE, 98, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(lblSaldoAdeudado)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(txtSaldoAdeudado, javax.swing.GroupLayout.PREFERRED_SIZE, 95, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addGroup(panelRound2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING, false)
                    .addComponent(btnNuevoAbono, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addComponent(btnNuevaCuota, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
                .addGap(24, 24, 24))
        );
        panelRound2Layout.setVerticalGroup(
            panelRound2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(panelRound2Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(panelRound2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                    .addGroup(panelRound2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                        .addComponent(lblAbonoInicial)
                        .addComponent(txtAbonoInicial, javax.swing.GroupLayout.PREFERRED_SIZE, 27, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addComponent(lblSaldoAdeudado))
                    .addGroup(panelRound2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                        .addComponent(btnNuevoAbono, javax.swing.GroupLayout.PREFERRED_SIZE, 27, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addComponent(txtSaldoAdeudado, javax.swing.GroupLayout.PREFERRED_SIZE, 24, javax.swing.GroupLayout.PREFERRED_SIZE)))
                .addGroup(panelRound2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(panelRound2Layout.createSequentialGroup()
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                        .addComponent(btnNuevaCuota, javax.swing.GroupLayout.PREFERRED_SIZE, 25, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addGap(43, 43, 43))
                    .addGroup(panelRound2Layout.createSequentialGroup()
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addGroup(panelRound2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(txtCuota, javax.swing.GroupLayout.PREFERRED_SIZE, 27, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(lblCuota))
                        .addContainerGap())))
        );

        lblSaldoAdeudado1.setFont(resourceMap.getFont("lblSaldoAdeudado1.font")); // NOI18N
        lblSaldoAdeudado1.setForeground(resourceMap.getColor("lblSaldoAdeudado1.foreground")); // NOI18N
        lblSaldoAdeudado1.setText(resourceMap.getString("lblSaldoAdeudado1.text")); // NOI18N
        lblSaldoAdeudado1.setName("lblSaldoAdeudado1"); // NOI18N

        lblSaldoAdeudado2.setFont(resourceMap.getFont("lblSaldoAdeudado2.font")); // NOI18N
        lblSaldoAdeudado2.setForeground(resourceMap.getColor("lblSaldoAdeudado2.foreground")); // NOI18N
        lblSaldoAdeudado2.setText(resourceMap.getString("lblSaldoAdeudado2.text")); // NOI18N
        lblSaldoAdeudado2.setName("lblSaldoAdeudado2"); // NOI18N

        javax.swing.GroupLayout panelImage3Layout = new javax.swing.GroupLayout(panelImage3);
        panelImage3.setLayout(panelImage3Layout);
        panelImage3Layout.setHorizontalGroup(
            panelImage3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(panelImage3Layout.createSequentialGroup()
                .addGroup(panelImage3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(panelImage3Layout.createSequentialGroup()
                        .addContainerGap()
                        .addComponent(lblSaldoAdeudado1)
                        .addGap(129, 129, 129)
                        .addComponent(lblSaldoAdeudado2)
                        .addGap(173, 173, 173))
                    .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, panelImage3Layout.createSequentialGroup()
                        .addGap(34, 34, 34)
                        .addComponent(panelRound2, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
                    .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, panelImage3Layout.createSequentialGroup()
                        .addContainerGap(34, Short.MAX_VALUE)
                        .addComponent(panelRect1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)))
                .addContainerGap())
        );
        panelImage3Layout.setVerticalGroup(
            panelImage3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(panelImage3Layout.createSequentialGroup()
                .addGroup(panelImage3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(lblSaldoAdeudado1)
                    .addComponent(lblSaldoAdeudado2))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(panelRound2, javax.swing.GroupLayout.PREFERRED_SIZE, 84, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 12, Short.MAX_VALUE)
                .addComponent(panelRect1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap())
        );

        javax.swing.GroupLayout panelImage2Layout = new javax.swing.GroupLayout(panelImage2);
        panelImage2.setLayout(panelImage2Layout);
        panelImage2Layout.setHorizontalGroup(
            panelImage2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(panelImage2Layout.createSequentialGroup()
                .addComponent(panelImage3, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );
        panelImage2Layout.setVerticalGroup(
            panelImage2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(panelImage2Layout.createSequentialGroup()
                .addComponent(panelImage3, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap(23, Short.MAX_VALUE))
        );

        tabbedPaneVertical1.addTab(resourceMap.getString("panelImage2.TabConstraints.tabTitle"), panelImage2); // NOI18N

        pnlCuotas.setBorder(new javax.swing.border.SoftBevelBorder(javax.swing.border.BevelBorder.RAISED));
        pnlCuotas.setName("pnlCuotas"); // NOI18N
        pnlCuotas.setOpaque(false);

        jScrollPane1.setName("jScrollPane1"); // NOI18N

        tblCuotas.setName("tblCuotas"); // NOI18N

        org.jdesktop.beansbinding.ELProperty eLProperty = org.jdesktop.beansbinding.ELProperty.create("${listCuotas}");
        org.jdesktop.swingbinding.JTableBinding jTableBinding = org.jdesktop.swingbinding.SwingBindings.createJTableBinding(org.jdesktop.beansbinding.AutoBinding.UpdateStrategy.READ_WRITE, this, eLProperty, tblCuotas);
        org.jdesktop.swingbinding.JTableBinding.ColumnBinding columnBinding = jTableBinding.addColumnBinding(org.jdesktop.beansbinding.ELProperty.create("${numRecibo}"));
        columnBinding.setColumnName("Num Recibo");
        columnBinding.setColumnClass(Integer.class);
        columnBinding.setEditable(false);
        columnBinding = jTableBinding.addColumnBinding(org.jdesktop.beansbinding.ELProperty.create("${valor}"));
        columnBinding.setColumnName("Valor");
        columnBinding.setColumnClass(Double.class);
        columnBinding = jTableBinding.addColumnBinding(org.jdesktop.beansbinding.ELProperty.create("${fecha}"));
        columnBinding.setColumnName("Fecha");
        columnBinding.setColumnClass(java.util.Date.class);
        columnBinding = jTableBinding.addColumnBinding(org.jdesktop.beansbinding.ELProperty.create("${abono}"));
        columnBinding.setColumnName("Abono");
        columnBinding.setColumnClass(Double.class);
        columnBinding.setEditable(false);
        columnBinding = jTableBinding.addColumnBinding(org.jdesktop.beansbinding.ELProperty.create("${saldo}"));
        columnBinding.setColumnName("Saldo");
        columnBinding.setColumnClass(Double.class);
        columnBinding.setEditable(false);
        columnBinding = jTableBinding.addColumnBinding(org.jdesktop.beansbinding.ELProperty.create("${interes}"));
        columnBinding.setColumnName("Interes");
        columnBinding.setColumnClass(Double.class);
        bindingGroup.addBinding(jTableBinding);
        jTableBinding.bind();
        jScrollPane1.setViewportView(tblCuotas);
        tblCuotas.getColumnModel().getColumn(0).setHeaderValue(resourceMap.getString("tblCuotas.columnModel.title0")); // NOI18N
        tblCuotas.getColumnModel().getColumn(1).setHeaderValue(resourceMap.getString("tblCuotas.columnModel.title1")); // NOI18N
        tblCuotas.getColumnModel().getColumn(2).setHeaderValue(resourceMap.getString("tblCuotas.columnModel.title2")); // NOI18N
        tblCuotas.getColumnModel().getColumn(3).setHeaderValue(resourceMap.getString("tblCuotas.columnModel.title3")); // NOI18N
        tblCuotas.getColumnModel().getColumn(4).setHeaderValue(resourceMap.getString("tblCuotas.columnModel.title5")); // NOI18N
        tblCuotas.getColumnModel().getColumn(5).setHeaderValue(resourceMap.getString("tblCuotas.columnModel.title4")); // NOI18N

        javax.swing.GroupLayout pnlCuotasLayout = new javax.swing.GroupLayout(pnlCuotas);
        pnlCuotas.setLayout(pnlCuotasLayout);
        pnlCuotasLayout.setHorizontalGroup(
            pnlCuotasLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(pnlCuotasLayout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jScrollPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 645, Short.MAX_VALUE)
                .addContainerGap())
        );
        pnlCuotasLayout.setVerticalGroup(
            pnlCuotasLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(pnlCuotasLayout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jScrollPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 342, Short.MAX_VALUE)
                .addContainerGap())
        );

        tabbedPaneVertical1.addTab(resourceMap.getString("pnlCuotas.TabConstraints.tabTitle"), pnlCuotas); // NOI18N

        panelRound1.setName("panelRound1"); // NOI18N

        lblCedulaCliente.setFont(resourceMap.getFont("lblCuota.font")); // NOI18N
        lblCedulaCliente.setForeground(resourceMap.getColor("lblCedulaCliente.foreground")); // NOI18N
        lblCedulaCliente.setText(resourceMap.getString("lblCedulaCliente.text")); // NOI18N
        lblCedulaCliente.setName("lblCedulaCliente"); // NOI18N

        txtCedulaCliente.setText(resourceMap.getString("txtCedulaCliente.text")); // NOI18N
        txtCedulaCliente.setName("txtCedulaCliente"); // NOI18N

        btnBuscarAdministraciónFinanciamiento.setFont(new java.awt.Font("Tahoma 12", 0, 12));
        btnBuscarAdministraciónFinanciamiento.setText(resourceMap.getString("btnBuscarAdministraciónFinanciamiento.text")); // NOI18N
        btnBuscarAdministraciónFinanciamiento.setName("btnBuscarAdministraciónFinanciamiento"); // NOI18N
        btnBuscarAdministraciónFinanciamiento.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnBuscarAdministraciónFinanciamientoActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout panelRound1Layout = new javax.swing.GroupLayout(panelRound1);
        panelRound1.setLayout(panelRound1Layout);
        panelRound1Layout.setHorizontalGroup(
            panelRound1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, panelRound1Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(panelRound1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                    .addComponent(btnBuscarAdministraciónFinanciamiento, javax.swing.GroupLayout.PREFERRED_SIZE, 116, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addGroup(javax.swing.GroupLayout.Alignment.LEADING, panelRound1Layout.createSequentialGroup()
                        .addComponent(lblCedulaCliente)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(txtCedulaCliente, javax.swing.GroupLayout.PREFERRED_SIZE, 420, javax.swing.GroupLayout.PREFERRED_SIZE)))
                .addGap(24, 24, 24))
        );
        panelRound1Layout.setVerticalGroup(
            panelRound1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(panelRound1Layout.createSequentialGroup()
                .addGroup(panelRound1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(panelRound1Layout.createSequentialGroup()
                        .addGap(21, 21, 21)
                        .addComponent(lblCedulaCliente))
                    .addGroup(panelRound1Layout.createSequentialGroup()
                        .addContainerGap()
                        .addComponent(txtCedulaCliente, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(btnBuscarAdministraciónFinanciamiento)
                .addContainerGap(9, Short.MAX_VALUE))
        );

        jLabel1.setFont(new java.awt.Font("Musicals", 0, 24));
        jLabel1.setForeground(resourceMap.getColor("jLabel1.foreground")); // NOI18N
        jLabel1.setText(resourceMap.getString("jLabel1.text")); // NOI18N
        jLabel1.setName("jLabel1"); // NOI18N

        btnGuardarTodo.setText(resourceMap.getString("btnGuardarTodo.text")); // NOI18N
        btnGuardarTodo.setName("btnGuardarTodo"); // NOI18N
        btnGuardarTodo.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnGuardarTodoActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout panelImage1Layout = new javax.swing.GroupLayout(panelImage1);
        panelImage1.setLayout(panelImage1Layout);
        panelImage1Layout.setHorizontalGroup(
            panelImage1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(panelImage1Layout.createSequentialGroup()
                .addGroup(panelImage1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(panelImage1Layout.createSequentialGroup()
                        .addContainerGap()
                        .addGroup(panelImage1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                            .addComponent(btnGuardarTodo, javax.swing.GroupLayout.PREFERRED_SIZE, 194, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addGroup(javax.swing.GroupLayout.Alignment.LEADING, panelImage1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING, false)
                                .addComponent(tabbedPaneVertical1, javax.swing.GroupLayout.Alignment.LEADING, 0, 0, Short.MAX_VALUE)
                                .addComponent(panelRound1, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))))
                    .addGroup(panelImage1Layout.createSequentialGroup()
                        .addGap(123, 123, 123)
                        .addComponent(jLabel1)))
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );
        panelImage1Layout.setVerticalGroup(
            panelImage1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, panelImage1Layout.createSequentialGroup()
                .addGap(6, 6, 6)
                .addComponent(jLabel1)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(panelRound1, javax.swing.GroupLayout.PREFERRED_SIZE, 81, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(tabbedPaneVertical1, javax.swing.GroupLayout.PREFERRED_SIZE, 408, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(btnGuardarTodo, javax.swing.GroupLayout.PREFERRED_SIZE, 25, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(panelImage1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(panelImage1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
        );

        bindingGroup.bind();

        pack();
    }// </editor-fold>//GEN-END:initComponents

    private void btnGuardarTodoActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnGuardarTodoActionPerformed
        if (error == true) {
            int opc = JOptionPane.showConfirmDialog(this, "No se puede GUARDAR los cambios.\nTermine el proceso de administración.\n\n¿Seguro que desea Salir?: \n\tNota: Si sale no se guardará ningún cambio.", "Error", JOptionPane.YES_NO_OPTION);
            if (opc == 0) {
                dispose();
                if (cambios == 2) {
                    da.guardar(administracionOriginal);
                }
            }
        } else {
            try {
                administracionEncontrada = da.buscarId(txtCedulaCliente.getText());
                administracionEditada = da.getEm().merge(administracionEncontrada);
                da.eliminar(administracionEditada);
                for (Cuota c : cuotasOriginales) {
                    c.setAdministracion(administracionOriginal);
                }
                da.guardar(administracionOriginal);
                JOptionPane.showMessageDialog(this, "Cambios Guardados");
                if (administracionEncontrada.getCuotas().size() == administracionEncontrada.getSolicitud().getPlazo()) {
                    double a1 = administracionEncontrada.getSaldo();
                    if (a1 == 0) {
                        JOptionPane.showMessageDialog(this, "No hay más cuotas por pagar\nLa Administración de este contrato finalizó.");
                        Cliente C1 = dc.buscarId(administracionEncontrada.getSolicitud().getClienteCedula());
                        Cliente C2 = dc.getEm().merge(C1);
                        dc.eliminar(C2);
                        Cliente cliente = new Cliente();
                        cliente = C1;
                        cliente.setGarante(null);
                        dc.guardar(cliente);
                    }
                }
                this.setVisible(false);
            } catch (NullPointerException e) {
                JOptionPane.showMessageDialog(this, "Error");
            }
        }

    }//GEN-LAST:event_btnGuardarTodoActionPerformed

    private void btnGuardarCuotaActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnGuardarCuotaActionPerformed
        if (txtCuota.getText().equals(txtValorCuota.getText()) == true && txtAbonoCuota.getText().equals("0") == false) {
            JOptionPane.showMessageDialog(this, "No se puede hacer un cuota con abono\nEs la última cuota.");
            txtAbonoCuota.setText("0");
            error = true;
        } else {
            cuotasRecuperadas = administracionEncontrada.getCuotas();
            administracionEditada = da.getEm().merge(administracionEncontrada);
            da.eliminar(administracionEditada);
            btnNuevaCuota.setEnabled(true);
            txtAbonoCuota.setEnabled(false);
            txtNumeroRecibo.setEnabled(false);
            btnGuardarCuota.setEnabled(false);
            dcrFechaCuota.setEnabled(false);
            cuota = new Cuota((Integer) txtNumeroRecibo.getValue(), dcrFechaCuota.getDate(), Double.parseDouble(txtValorCuota.getText()));
            cuota.setInteres(administracionEncontrada.getSolicitud().getInteres());
            cuota.setSaldo(administracionEncontrada.getSaldo() - administracionEncontrada.getSolicitud().getCuotaMensual());
            //Verifica si existe una cantidad en el abono, por que puede ser solo cuota O  solo abono O cuota con abono
            if (Double.parseDouble(txtAbonoCuota.getText()) > 0) {
                double interes = administracionEncontrada.getSolicitud().getInteres();
                int cuotasFaltantes = 0;
                //panelAbono.setVisible(true);
                cuota.setAbono(Double.parseDouble(txtAbonoCuota.getText()));
                //verifica si solo es abono o una cuota con abono
                if (txtValorCuota.getText().equals("0") == true) {
                    /*
                     *SOLO ABONO
                     */
                    cuota.setValor(0);
                    cuota.setInteres(0);
                    cuotasFaltantes = administracionEncontrada.getSolicitud().getPlazo() - administracionEncontrada.getCuotas().size();
                    cuotasRecuperadas.add(cuota);
                    for (Cuota c : cuotasRecuperadas) {
                        c.setAdministracion(administracionEncontrada);
                    }
                    administracionEncontrada.setCuotas(cuotasRecuperadas);
                    double valorInteres = ((administracionEncontrada.getSolicitud().getSaldoAdeudado() * interes) / 100) * cuotasFaltantes;
                    administracionEncontrada.setSaldo(administracionEncontrada.getSaldo() - valorInteres - Double.parseDouble(txtAbonoCuota.getText()));
                    txtSaldoAdeudadoSinInteres.setText(String.valueOf(ver.redondearCantidad(administracionEncontrada.getSaldo())));
                    cuota.setSaldo(administracionEncontrada.getSaldo());
                    spnNuevoPlazo.setEnabled(true);
                    btnGuardarNuevoPlazo.setEnabled(true);
                    btnGuardarCuota.setEnabled(false);
                    cambios = 2;
                } else {
                    /*
                     *CUOTA CON ABONO
                     */
                    cuotasRecuperadas.add(cuota);
                    for (Cuota c : cuotasRecuperadas) {
                        c.setAdministracion(administracionEncontrada);
                    }
                    administracionEncontrada.setCuotas(cuotasRecuperadas);
                    administracionEncontrada.setSaldo(administracionEncontrada.getSaldo() - cuota.getValor());
                    txtCuota.setText(String.valueOf(administracionEncontrada.getSolicitud().getCuotaMensual()));
                    txtSaldoAdeudado.setText(String.valueOf(administracionEncontrada.getSaldo()));
                    txtAbonoInicial.setText(String.valueOf(administracionEncontrada.getSolicitud().getEntrada()));
                    spnNuevoPlazo.setEnabled(true);
                    btnGuardarNuevoPlazo.setEnabled(true);
                    btnGuardarCuota.setEnabled(false);
                    interes = administracionEncontrada.getSolicitud().getInteres();
                    cuotasFaltantes = administracionEncontrada.getSolicitud().getPlazo() - administracionEncontrada.getCuotas().size();
                    administracionEncontrada.setSaldo(((administracionEncontrada.getSolicitud().getCuotaMensual() - (((administracionEncontrada.getSolicitud().getSaldoAdeudado() * (interes)) / 100))) * cuotasFaltantes) - Double.parseDouble(txtAbonoCuota.getText()));
                    txtSaldoAdeudadoSinInteres.setText(String.valueOf(administracionEncontrada.getSaldo()));
                    cambios = 2;
                }
                listCuotas.add(cuota);
                int cont = 0;
                for (Cuota c : administracionOriginal.getCuotas()) {
                    if (c.getValor() == 0) {
                        cont = cont + 1;
                    }
                }
                spnNuevoPlazo.setValue(administracionOriginal.getSolicitud().getPlazo() - (administracionOriginal.getCuotas().size() - cont));
                this.setVisible(false);
                JOptionPane.showMessageDialog(this, "Las Cuotas pagadas son: " + (administracionOriginal.getCuotas().size() - cont) + "\nEl plazo inicial es de: " + administracionOriginal.getSolicitud().getPlazo() + "\n" + "Quedan " + spnNuevoPlazo.getValue() + " cuotas.");
                vistaValores.setLocationRelativeTo(this);
                vistaValores.setVisible(true);
                error = true;
            } else {
                /*
                 *SOLO CUOTA
                 */
                cuotasRecuperadas.add(cuota);
                for (Cuota c : cuotasRecuperadas) {
                    c.setAdministracion(administracionEncontrada);
                }
                administracionEncontrada.setCuotas(cuotasRecuperadas);
                administracionEncontrada.setSaldo(administracionEncontrada.getSaldo() - cuota.getValor());
                da.guardar(administracionEncontrada);
                cambios = 2;
                txtCuota.setText(String.valueOf(administracionEncontrada.getSolicitud().getCuotaMensual()));
                txtSaldoAdeudado.setText(String.valueOf(administracionEncontrada.getSaldo()));
                txtAbonoInicial.setText(String.valueOf(administracionEncontrada.getSolicitud().getEntrada()));
                listCuotas.add(cuota);
                btnNuevaCuota.setEnabled(true);
                btnNuevoAbono.setEnabled(true);
                error = false;
            }
        }
        System.out.println(cambios);
    }//GEN-LAST:event_btnGuardarCuotaActionPerformed

    private void btnGuardarNuevoPlazoActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnGuardarNuevoPlazoActionPerformed
        String por = "";
        int plazoAnteriorPagado = administracionEncontrada.getCuotas().size();
        int nuevoPlazo = (Integer) spnNuevoPlazo.getValue();
        if (nuevoPlazo > 0) {
            try {
                por = JOptionPane.showInputDialog("Ingrese el porcentaje de interés: ");
                double porcentaje = Double.parseDouble(por);
                administracionEncontrada.getSolicitud().setInteres(porcentaje);
                try {
                    administracionEncontrada.getSolicitud().setPlazo(plazoAnteriorPagado + nuevoPlazo);
                    administracionEncontrada.getSolicitud().setSaldoAdeudado(Double.parseDouble(txtSaldoAdeudadoSinInteres.getText()));
                    Control control = new Control();
                    double cu = control.redondearCantidad(administracionEncontrada.getSolicitud().calCuota(nuevoPlazo));
                    txtNuevoValorCuotas.setText(String.valueOf(cu));
                    administracionEncontrada.getSolicitud().setCuotaMensual(cu);
                    btnGuardar.setEnabled(true);
                } catch (NumberFormatException e) {
                    JOptionPane.showMessageDialog(this, "Ingrese el Plazo: ", "Error de Datos", JOptionPane.ERROR_MESSAGE);
                }
            } catch (Exception e) {
                if (por.equals("")) {
                    JOptionPane.showMessageDialog(this, "Ingrese un interés correcto: ", "Error de Datos", JOptionPane.ERROR_MESSAGE);
                }
            }
        } else {
            JOptionPane.showMessageDialog(this, "Ingrese un valo de Plazo Correcto");
        }
    }//GEN-LAST:event_btnGuardarNuevoPlazoActionPerformed

    private void btnGuardarActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnGuardarActionPerformed
        administracionEncontrada.setSaldo(Double.parseDouble(txtNuevoValorCuotas.getText()) * (Integer) spnNuevoPlazo.getValue());
        txtSaldoAdeudado.setText(String.valueOf(administracionEncontrada.getSaldo()));
        da.guardar(administracionEncontrada);
        cambios = 0;
        txtCuota.setText(String.valueOf(administracionEncontrada.getSolicitud().getCuotaMensual()));
        txtSaldoAdeudado.setText(String.valueOf(administracionEncontrada.getSaldo()));
        txtAbonoInicial.setText(String.valueOf(administracionEncontrada.getSolicitud().getEntrada()));
        btnGuardar.setEnabled(false);
        btnGuardarNuevoPlazo.setEnabled(false);
        txtSaldoAdeudadoSinInteres.setText("0");
        txtNuevoValorCuotas.setText("0");
        spnNuevoPlazo.setValue(0);
        btnNuevoAbono.setEnabled(true);
        btnNuevaCuota.setEnabled(true);
        error = false;
        //panelAbono.setVisible(false);
        System.out.println(cambios);
        vistaValores.setVisible(false);
        this.setVisible(true);
    }//GEN-LAST:event_btnGuardarActionPerformed

private void btnNuevaCuotaActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnNuevaCuotaActionPerformed
    btnNuevoAbono.setEnabled(false);
    btnNuevaCuota.setEnabled(false);
    if (administracionEncontrada.getCuotas().size() != administracionEncontrada.getSolicitud().getPlazo()) {
        txtAbonoCuota.setEnabled(true);
        txtNumeroRecibo.setEnabled(true);
        btnGuardarCuota.setEnabled(true);
        btnNuevaCuota.setEnabled(false);
        dcrFechaCuota.setEnabled(true);
        txtValorCuota.setText(String.valueOf(administracionEncontrada.getSolicitud().getCuotaMensual()));
        txtAbonoCuota.setText("0");
        dcrFechaCuota.setDate(new Date());
        txtNumeroRecibo.setValue(administracionEncontrada.getCuotas().size() + 1);
        cambios = 1;
        error = true;
    } else {
        if (administracionEncontrada.getCuotas().size() == administracionEncontrada.getSolicitud().getPlazo()) {
            double a1 = administracionEncontrada.getSaldo();
            if (a1 == 0) {
                JOptionPane.showMessageDialog(this, "No hay más cuotas por pagar\nGuarde los cambios y proceda a Imprimir el Contrato de Compra/Venta");
                error = false;
            }
        }
    }
    System.out.println(cambios);
}//GEN-LAST:event_btnNuevaCuotaActionPerformed

private void btnNuevoAbonoActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnNuevoAbonoActionPerformed
    if (administracionEncontrada.getCuotas().size() == administracionEncontrada.getSolicitud().getPlazo()) {
        double a1 = administracionEncontrada.getSaldo();
        if (a1 == 0) {
            JOptionPane.showMessageDialog(this, "No hay más cuotas por pagar\nLa Administración de este contrato finalizó.");
            error = false;
        }
    } else {
        txtAbonoCuota.setEnabled(true);
        txtValorCuota.setText("0");
        txtNumeroRecibo.setValue(administracionEncontrada.getCuotas().size() + 1);
        btnGuardarCuota.setEnabled(true);
        btnNuevoAbono.setEnabled(false);
        btnNuevaCuota.setEnabled(false);
        cambios = 1;
        error = true;
    }
    System.out.println(cambios);
}//GEN-LAST:event_btnNuevoAbonoActionPerformed

private void btnBuscarAdministraciónFinanciamientoActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnBuscarAdministraciónFinanciamientoActionPerformed
    da = new DaoAdministracionFinanciamiento();
    listCuotas.clear();
    try {
        administracionEncontrada = da.buscarId(txtCedulaCliente.getText());
        if (administracionEncontrada.getCuotas().size() == administracionEncontrada.getSolicitud().getPlazo()) {
            double a1 = administracionEncontrada.getSaldo();
            if (a1 == 0) {
                JOptionPane.showMessageDialog(this, "No hay más cuotas por pagar\nLa Administración de este contrato finalizó.");
                dispose();
            }
        }
        administracionOriginal = da.buscarId(txtCedulaCliente.getText());
        cuotasOriginales = da.buscarId(txtCedulaCliente.getText()).getCuotas();
        btnNuevaCuota.setEnabled(true);
        btnNuevoAbono.setEnabled(true);
        if (administracionEncontrada.getSaldo() < 0) {
            txtSaldoAdeudado.setText("0");
        } else {
            txtSaldoAdeudado.setText(String.valueOf(administracionEncontrada.getSaldo()));
        }
        txtNumeroRecibo.setValue(administracionEncontrada.getCuotas().size());
        txtCuota.setText(String.valueOf(administracionEncontrada.getSolicitud().getCuotaMensual()));
        txtAbonoInicial.setText(String.valueOf(administracionEncontrada.getSolicitud().getEntrada()));
        cuotas = administracionEncontrada.getCuotas();
        listCuotas.addAll(cuotas);
        btnBuscarAdministraciónFinanciamiento.setEnabled(false);
    } catch (NullPointerException e) {
        JOptionPane.showMessageDialog(this, "No existe ninguna administración con código: " + " " + txtCedulaCliente.getText());
    }
}//GEN-LAST:event_btnBuscarAdministraciónFinanciamientoActionPerformed
    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JButton btnBuscarAdministraciónFinanciamiento;
    private javax.swing.JButton btnGuardar;
    private javax.swing.JButton btnGuardarCuota;
    private javax.swing.JButton btnGuardarNuevoPlazo;
    private javax.swing.JButton btnGuardarTodo;
    private javax.swing.JButton btnNuevaCuota;
    private javax.swing.JButton btnNuevoAbono;
    private com.toedter.calendar.JDateChooser dcrFechaCuota;
    private javax.swing.JLabel jLabel1;
    private javax.swing.JLabel jLabel11;
    private javax.swing.JLabel jLabel12;
    private javax.swing.JLabel jLabel13;
    private javax.swing.JLabel jLabel6;
    private javax.swing.JLabel jLabel7;
    private javax.swing.JLabel jLabel8;
    private javax.swing.JScrollPane jScrollPane1;
    private javax.swing.JLabel lblAbonoCuota;
    private javax.swing.JLabel lblAbonoInicial;
    private javax.swing.JLabel lblCedulaCliente;
    private javax.swing.JLabel lblCuota;
    private javax.swing.JLabel lblFechaCuota;
    private javax.swing.JLabel lblNumRecibo;
    private javax.swing.JLabel lblSaldoAdeudado;
    private javax.swing.JLabel lblSaldoAdeudado1;
    private javax.swing.JLabel lblSaldoAdeudado2;
    private javax.swing.JLabel lblValorCuota;
    private org.edisoncor.gui.panel.PanelImage panelImage1;
    private org.edisoncor.gui.panel.PanelImage panelImage2;
    private org.edisoncor.gui.panel.PanelImage panelImage3;
    private org.edisoncor.gui.panel.PanelImage panelImage4;
    private org.edisoncor.gui.panel.PanelRect panelRect1;
    private org.edisoncor.gui.panel.PanelRound panelRound1;
    private org.edisoncor.gui.panel.PanelRound panelRound2;
    private org.edisoncor.gui.panel.PanelRound panelRound3;
    private javax.swing.JPanel pnlCuota;
    private javax.swing.JPanel pnlCuotas;
    private javax.swing.JSpinner spnNuevoPlazo;
    private org.edisoncor.gui.tabbedPane.TabbedPaneVertical tabbedPaneVertical1;
    private javax.swing.JTable tblCuotas;
    private javax.swing.JTextField txtAbonoCuota;
    private javax.swing.JTextField txtAbonoInicial;
    private javax.swing.JTextField txtCedulaCliente;
    private javax.swing.JTextField txtCuota;
    private javax.swing.JTextField txtNuevoValorCuotas;
    private javax.swing.JSpinner txtNumeroRecibo;
    private javax.swing.JTextField txtSaldoAdeudado;
    private javax.swing.JTextField txtSaldoAdeudadoSinInteres;
    private javax.swing.JTextField txtValorCuota;
    private javax.swing.JDialog vistaValores;
    private org.jdesktop.beansbinding.BindingGroup bindingGroup;
    // End of variables declaration//GEN-END:variables
    List<Cuota> cuotas = new ArrayList<Cuota>();

    public List<Cuota> getCuotas() {
        return cuotas;
    }

    public void setCuotas(List<Cuota> cuotas) {
        this.cuotas = cuotas;
    }
    ObservableList<Cuota> listCuotas = org.jdesktop.observablecollections.ObservableCollections.observableList(cuotas);

    public ObservableList<Cuota> getListCuotas() {
        return listCuotas;
    }

    public void setListCuotas(ObservableList<Cuota> listCuotas) {
        this.listCuotas = listCuotas;
    }
}
